﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Device.Location;
using System.IO.IsolatedStorage;

namespace TaxiTouchClient
{
    public partial class Taxi_accueil : PhoneApplicationPage
    {
        GeoCoordinate coordTaxi;
        GeoCoordinateWatcher geoWatcherTaxi;
        public Taxi_accueil()
        {
            InitializeComponent();

            if (IsolatedStorageSettings.ApplicationSettings.Contains("DemandeActuelleTaxi"))
            {
                PhoneApp1.ServiceReference1.Demande demande = (PhoneApp1.ServiceReference1.Demande)IsolatedStorageSettings.ApplicationSettings["DemandeActuelleTaxi"];
                txtDepart.Text = demande.Adresse_Origine;
                txtDestination.Text = demande.Adresse_Destination;
                txtStatut.Text = "Vous avez une mission en cours";
            }
            else
            {
                txtDepart.Text = "";
                txtDestination.Text = "";
                txtStatut.Text = "Aucune demande prise en charge";
            }

            /*
            try
            {
                geoWatcherTaxi = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
                geoWatcherTaxi.Start();

                coordTaxi = geoWatcherTaxi.Position.Location;
                IsolatedStorageSettings.ApplicationSettings.Add("LocationTaxi", coordTaxi);
            }
            catch(Exception e)
            {
                MessageBox.Show("Nous n'avons pas pu récupérer votre position, veuillez réessayer");
            }
            */
        }

        private void DemandesClients_TaxiAccueil_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Pages/Taxi_demandes_clients.xaml", UriKind.Relative));
        }
    }
}